package com.jykj.modbus.system.runtime.mvc;

import com.jykj.util.config.AppConfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 资源映射路径
 */
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        String path;
        String os = System.getProperty("os.name");
        if(os.toLowerCase().startsWith("win")) {
            path = AppConfig.getProperty("filepath.shopImageWin");
        } else {
            path = AppConfig.getProperty("filepath.shopImageLinux");
        }
        registry.addResourceHandler("/images/**").addResourceLocations("file:"+path);
    }
}
